package com.yuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuan.entity.Dto.EmpLoginDto;
import com.yuan.entity.Emp;
import com.yuan.mapper.EmpMapper;
import com.yuan.service.IEmpService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 员工表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-11-05
 */
@Service
public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements IEmpService {

    @Override
    public Emp login(EmpLoginDto empLoginDto) {

        LambdaQueryWrapper<Emp> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Emp::getUsername, empLoginDto.getUsername());
        Emp emp = getOne(wrapper);

        if (emp.getPassword() == empLoginDto.getPassword()) {
            throw new RuntimeException("密码错误");
        }

        return emp;

    }
}
